package org.atlantis.grosbeak.pot.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;

/**
 * 把数据库中查询出来的字段的数据映射到一个Long中。
 * 
 * @author <a href="mailto:seenoevil.cn@gmail.com">SeeNoEvil</a>
 * 
 */
public class LongFieldMapper implements FieldMapper<Long> {

	public static final LongFieldMapper ME = new LongFieldMapper();

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.atlantis.grosbeak.pot.mapper.FieldMapper#getTypes()
	 */
	public int[] getTypes() {
		return new int[] { Types.BIGINT };
	}

	public Long mapField(ResultSet rs, int type, String column, boolean nullable)
			throws SQLException {
		long result = rs.getLong(column);
		if (nullable && rs.wasNull())
			return null;
		return Long.valueOf(result);
	}
}
